package com.sdgakj.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;

import javax.persistence.*;
import java.io.Serializable;
import java.util.List;

@Entity
@Table(name = "f_cities")
public class ShtCity implements Serializable {

    private static final long serialVersionUID = 1L;
    private int id;
    private String name;
    private String firstLetter;
    private ShtProvince province;
    private List<ShtDistrict> shtDistrict;

    public ShtCity() {
    }

    public ShtCity(int id) {
        this.id = id;
    }

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    public int getId() {
        return this.id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getFirstLetter() {
        return firstLetter;
    }

    public void setFirstLetter(String firstLetter) {
        this.firstLetter = firstLetter;
    }

    // JPA 基于USER_ID列的多对一关系定义
    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "pid")
    @JsonIgnore
    public ShtProvince getProvince() {
        return province;
    }

    public void setProvince(ShtProvince province) {
        this.province = province;
    }

    @OneToMany(fetch = FetchType.EAGER)
    @JoinColumn(name = "cid")
    public List<ShtDistrict> getShtDistrict() {
        return shtDistrict;
    }

    public void setShtDistrict(List<ShtDistrict> shtDistrict) {
        this.shtDistrict = shtDistrict;
    }

}
